home *** CD-ROM | disk | FTP | other *** search
/ Trading on the Edge / Trading On The Edge - CD-ROM Toolkit (Wayzata Technology)(2031)(1994).bin / mac / Mac_Files / Vendor Demos / Mathematica / MathReader / Mathematica Demo Notebooks / Point Plots and Space Curves < prev    next >
Text File  |  1993-05-04  |  14KB  |  244 lines

  1. (*^
  2. ::[    Information =
  3.  
  4.     "This is a Mathematica Notebook file.  It contains ASCII text, and can be
  5.     transferred by email, ftp, or other text-file transfer utility.  It should
  6.     be read or edited using a copy of Mathematica or MathReader.  If you 
  7.     received this as email, use your mail application or copy/paste to save 
  8.     everything from the line containing (*^ down to the line containing ^*)
  9.     into a plain text file.  On some systems you may have to give the file a 
  10.     name ending with ".ma" to allow Mathematica to recognize it as a Notebook.
  11.     The line below identifies what version of Mathematica created this file,
  12.     but it can be opened using any other version as well.";
  13.  
  14.     FrontEndVersion = "Macintosh Mathematica Notebook Front End Version 2.2";
  15.  
  16.     MacintoshStandardFontEncoding; 
  17.     
  18.     fontset = title, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, e8,  24, "Times"; 
  19.     fontset = subtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, e6,  18, "Times"; 
  20.     fontset = subsubtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, italic, e6,  14, "Times"; 
  21.     fontset = section, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, grayBox, M22, bold, a20,  18, "Times"; 
  22.     fontset = subsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, blackBox, M19, bold, a15,  14, "Times"; 
  23.     fontset = subsubsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, whiteBox, M18, bold, a12,  12, "Times"; 
  24.     fontset = text, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7,  12, "Times"; 
  25.     fontset = smalltext, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7,  10, "Times"; 
  26.     fontset = input, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeInput, M42, N23, bold, L-5,  12, "Courier"; 
  27.     fontset = output, output, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L-5,  12, "Courier"; 
  28.     fontset = message, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, R65535, L-5,  12, "Courier"; 
  29.     fontset = print, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L-5,  12, "Courier"; 
  30.     fontset = info, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, B65535, L-5,  12, "Courier"; 
  31.     fontset = postscript, PostScript, formatAsPostScript, output, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeGraphics, M7, l34, w282, h287,  12, "Courier"; 
  32.     fontset = name, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, italic,  10, "Geneva"; 
  33.     fontset = header, inactive, noKeepOnOnePage, preserveAspect, M7,  12, "Times"; 
  34.     fontset = leftheader, inactive, L2,  12, "Times"; 
  35.     fontset = footer, inactive, noKeepOnOnePage, preserveAspect, center, M7,  12, "Times"; 
  36.     fontset = leftfooter, inactive, L2,  12, "Times"; 
  37.     fontset = help, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7,  10, "Times"; 
  38.     fontset = clipboard, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7,  12, "Times"; 
  39.     fontset = completions, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7,  12, "Times"; 
  40.     fontset = special1, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7,  12, "Times"; 
  41.     fontset = special2, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7,  12, "Times"; 
  42.     fontset = special3, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7,  12, "Times"; 
  43.     fontset = special4, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7,  12, "Times"; 
  44.     fontset = special5, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7,  12, "Times"; 
  45.     paletteColors = 128; automaticGrouping; currentKernel; 
  46. ]
  47. :[font = title; inactive; preserveAspect; rightWrapOffset = 431; fontName = "B Helvetica Bold"; startGroup]
  48. Point Plots and Space Curves
  49. by Theodore W. Gray
  50. ;[s]
  51. 4:0,1;28,0;29,2;48,0;49,-1;
  52. 3:2,23,17,Courier,1,24,0,0,0;1,18,14,Chicago,1,14,0,0,0;1,16,12,Chicago,3,12,0,0,0;
  53. :[font = text; inactive; preserveAspect; rightWrapOffset = 431]
  54. This Notebook defines the functions PointPlot, PointPlot3D, PointParamPlot3D, SpaceCurve, and PointSpaceCurve.  These functions let you make discrete point plots in two and three dimensions.  The SpaceCurve and PointSpaceCurve functions let you make three-dimensional functions of one parameter (lines or points in 3D).
  55. ;[s]
  56. 11:0,0;36,1;45,0;47,1;58,0;60,1;76,0;78,1;88,0;94,1;109,0;320,-1;
  57. 2:6,13,9,Times,0,12,0,0,0;5,13,9,Times,1,12,0,0,0;
  58. :[font = section; inactive; Cclosed; preserveAspect; rightWrapOffset = 431; startGroup]
  59. Examples
  60. :[font = text; inactive; preserveAspect; rightWrapOffset = 431]
  61. Each of the functions defined in this Notebook is a variation of either Plot, Plot3D, or ParametricPlot3D.  The arguments are quite similar to these standard functions.  
  62. Following are descriptions of each of the functions.
  63. ;[s]
  64. 7:0,0;72,1;76,0;78,1;84,0;89,1;105,0;224,-1;
  65. 2:4,13,9,Times,0,12,0,0,0;3,12,9,Times,1,10,0,0,0;
  66. :[font = subsection; inactive; Cclosed; preserveAspect; rightWrapOffset = 431; startGroup]
  67. PointPlot
  68. ;[s]
  69. 2:0,1;9,0;10,-1;
  70. 2:1,19,14,Geneva,1,14,0,0,0;1,16,12,Times,1,14,0,0,0;
  71. :[font = text; inactive; preserveAspect; rightWrapOffset = 431]
  72. PointPlot[ f, {x, min, max, (step)}] produces a plot of f(x) vs. x.  Here is an example:
  73. ;[s]
  74. 3:0,0;61,1;64,0;89,-1;
  75. 2:2,17,12,Times,0,12,0,0,0;1,17,12,Times,2,12,0,0,0;
  76. :[font = input; preserveAspect; rightWrapOffset = 431; startGroup]
  77. PointPlot[Sin[x], {x, 0, 2 Pi, 0.2}]
  78. :[font = postscript; PICT; formatAsPICT; output; inactive; preserveAspect; rightWrapOffset = 431; pictureLeft = 67; pictureWidth = 243; pictureHeight = 147; pictureID = 2570]
  79.  
  80. :[font = output; output; inactive; preserveAspect; rightWrapOffset = 431; endGroup; endGroup]
  81. The Unformatted text for this cell was not generated.
  82. Use options in the Actions Settings dialog box to control
  83. when Unformatted text is generated.
  84. ;[o]
  85. -Graphics-
  86. :[font = subsection; inactive; Cclosed; preserveAspect; rightWrapOffset = 431; startGroup]
  87. PointPlot3D
  88. :[font = text; inactive; preserveAspect; rightWrapOffset = 431]
  89.      PointPlot3D[ f, {x, min, max, (step)}, {y, min, max, (step)}] produces a plot of f(x, y), plotted with points instead of surfaces.
  90. :[font = input; preserveAspect; rightWrapOffset = 431; startGroup]
  91. PointPlot3D[x y, {x, -4, 4, 0.5}, {y, -4, 4, 0.5}, 
  92.             BoxRatios->{1,1,1}]
  93. :[font = postscript; PICT; formatAsPICT; output; inactive; preserveAspect; rightWrapOffset = 431; pictureLeft = 107; pictureWidth = 202; pictureHeight = 198; pictureID = 25009]
  94.  
  95. :[font = output; output; inactive; preserveAspect; rightWrapOffset = 431; endGroup; endGroup]
  96. The Unformatted text for this cell was not generated.
  97. Use options in the Actions Settings dialog box to control
  98. when Unformatted text is generated.
  99. ;[o]
  100. -Graphics3D-
  101. :[font = subsection; inactive; Cclosed; preserveAspect; rightWrapOffset = 431; startGroup]
  102. PointParamPlot3D
  103. :[font = text; inactive; preserveAspect; rightWrapOffset = 431]
  104.      PointParamPlot3D[{x,y,z}, {u, min, max, (step)}, {v, min, max, (step)}] produces a parametric plot of (x(u,v), y(u,v), z(u,v)), plotted with points instead of surfaces.
  105. :[font = input; preserveAspect; rightWrapOffset = 431; startGroup]
  106. PointParamPlot3D[{Sin[u] Cos[v], 
  107.                         Sin[u] Sin[v], Cos[u]}, 
  108.         {u, 0, Pi, Pi/15}, {v, 0, 2 Pi, Pi/15}, 
  109.         BoxRatios->{1,1,1}]
  110. :[font = postscript; PICT; formatAsPICT; output; inactive; preserveAspect; rightWrapOffset = 431; pictureLeft = 113; pictureWidth = 205; pictureHeight = 201; pictureID = 29261]
  111.  
  112. :[font = output; output; inactive; preserveAspect; rightWrapOffset = 431; endGroup; endGroup]
  113. The Unformatted text for this cell was not generated.
  114. Use options in the Actions Settings dialog box to control
  115. when Unformatted text is generated.
  116. ;[o]
  117. -Graphics3D-
  118. :[font = subsection; inactive; Cclosed; preserveAspect; rightWrapOffset = 431; startGroup]
  119. SpaceCurve
  120. :[font = text; inactive; preserveAspect; rightWrapOffset = 431]
  121.      SpaceCurve[{x,y,z}, {u, min, max, (step)}] produces a parametric plot of (x(u), y(u), z(u)), with the calculated points connected by straight lines.
  122. :[font = input; preserveAspect; rightWrapOffset = 431; startGroup]
  123. SpaceCurve[{u Sin[u], u Cos[u], u}, 
  124.            {u, 0, 15, 0.15}, BoxRatios->{1,1,1}]
  125. :[font = postscript; PICT; formatAsPICT; output; inactive; preserveAspect; rightWrapOffset = 431; pictureLeft = 107; pictureWidth = 202; pictureHeight = 198; pictureID = 1282]
  126.  
  127. :[font = output; output; inactive; preserveAspect; rightWrapOffset = 431; endGroup; endGroup]
  128. The Unformatted text for this cell was not generated.
  129. Use options in the Actions Settings dialog box to control
  130. when Unformatted text is generated.
  131. ;[o]
  132. -Graphics3D-
  133. :[font = subsection; inactive; Cclosed; preserveAspect; rightWrapOffset = 431; startGroup]
  134. PointSpaceCurve
  135. :[font = text; inactive; preserveAspect; rightWrapOffset = 431]
  136.     PointSpaceCurve[{x,y,z}, {u, min, max, (step)}] produces a parametric plot of (x(u), y(u), z(u)), with the calculated points shown as dots.
  137. :[font = input; preserveAspect; rightWrapOffset = 431; startGroup]
  138. PointSpaceCurve[{u Sin[u], u Cos[u], u^2}, 
  139.             {u, 0, 15, 0.30}, BoxRatios->{1,1,1}]
  140. :[font = postscript; PICT; formatAsPICT; output; inactive; preserveAspect; rightWrapOffset = 431; pictureLeft = 114; pictureWidth = 198; pictureHeight = 194; pictureID = 25529]
  141.  
  142. :[font = output; output; inactive; preserveAspect; rightWrapOffset = 431; endGroup; endGroup; endGroup]
  143. The Unformatted text for this cell was not generated.
  144. Use options in the Actions Settings dialog box to control
  145. when Unformatted text is generated.
  146. ;[o]
  147. -Graphics3D-
  148. :[font = section; inactive; Cclosed; pageBreak; preserveAspect; rightWrapOffset = 431; startGroup]
  149. Implementation
  150. :[font = text; inactive; preserveAspect; rightWrapOffset = 431]
  151. Remove previous definitions for the functions defined in this file:
  152. :[font = input; preserveAspect; rightWrapOffset = 431]
  153. Remove[PointPlot, PointParamPlot3D, PointPlot3D,
  154.         SpaceCurve, PointSpaceCurve];
  155. :[font = text; inactive; preserveAspect; rightWrapOffset = 431]
  156. Begin this package:
  157. :[font = input; preserveAspect; rightWrapOffset = 431]
  158. BeginPackage["PointPlots`"];
  159. :[font = text; inactive; preserveAspect; rightWrapOffset = 431]
  160. Define the usage strings for each of the functions:
  161. :[font = input; preserveAspect; rightWrapOffset = 431]
  162. PointPlot::usage =
  163.     "PointPlot[f, {u, u0, u1, (du)}], (options)] \
  164.     produces a 2D plot made out of points. \
  165.     Options are passed to Show[]";
  166. :[font = input; preserveAspect; rightWrapOffset = 431]
  167. PointPlot3D::usage =
  168.     "PointPlot3D[f, {x, x0, x1, (dx)}, \
  169.     {y, y0, y1, (dy)}, (options)] \
  170.     produces a 3D plot made out of points. \
  171.     Options are passed to Show[]";
  172. :[font = input; preserveAspect; rightWrapOffset = 431]
  173. PointParamPlot3D::usage =
  174.     "PointParamPlot3D[{x, y, z}, {u, u0, u1, (du)}, \
  175.     {v, v0, v1, (dv)}, (options)] \
  176.     produces a 3D parametric plot made out of points. \ 
  177.     Options are passed to Show[]";
  178. :[font = input; preserveAspect; rightWrapOffset = 431]
  179. SpaceCurve::usage =
  180.     "SpaceCurve[{x, y, z}, {u, u0, u1, (du)}, \
  181.     (options)] \
  182.     produces a 3D space curve. \
  183.     Options are passed to Show[]";
  184. :[font = input; preserveAspect; rightWrapOffset = 431]
  185. PointSpaceCurve::usage =
  186.     "PointSpaceCurve[{x, y, z}, \
  187.     {u, u0, u1, (du)}, (options)] \
  188.     produces a set of points in 3D. \
  189.     Options are passed to Show[]";
  190. :[font = text; inactive; preserveAspect; rightWrapOffset = 431]
  191. Begin the private part of this package:
  192. :[font = input; preserveAspect; rightWrapOffset = 431]
  193. Begin["`Private`"];
  194. `plotpoints = PlotPoints /. Options[Plot3D]; 
  195. :[font = text; inactive; preserveAspect; rightWrapOffset = 431]
  196. Define PointPlot:
  197. :[font = input; preserveAspect; rightWrapOffset = 431]
  198. Attributes[PointPlot] = {HoldFirst};
  199.  
  200. PointPlot[function_, range:{x_,___}, options___] := 
  201.             ListPlot[Table[{x, function}, range], options];
  202. :[font = text; inactive; preserveAspect; rightWrapOffset = 431]
  203. Define PointParamPlot3D:
  204. :[font = input; preserveAspect; rightWrapOffset = 431]
  205. Attributes[PointParamPlot3D] = {HoldFirst};
  206.  
  207. PointParamPlot3D[fun:{_, _, _}, 
  208.     {u_, u0_, u1_, du_:((u1-u0)/(plotpoints-1))}, 
  209.     {v_, v0_, v1_, dv_:((v1-v0)/(plotpoints-1))}, opts___] :=
  210.     Show[Graphics3D[Table[Point[N[fun]], 
  211.                         {u, u0, u1, du}, 
  212.                         {v, v0, v1, dv}]], opts];
  213. :[font = text; inactive; preserveAspect; rightWrapOffset = 431]
  214. Define PointPlot3D (in terms of PointParamPlot3D):
  215. :[font = input; preserveAspect; rightWrapOffset = 431]
  216. Attributes[PointPlot3D] = {HoldFirst};
  217.  
  218. PointPlot3D[fun_, ulim:{u_, ___}, vlim:{v_, ___}, opts___] :=
  219.     PointParamPlot3D[ {u, v, fun}, ulim, vlim, opts];
  220. :[font = text; inactive; preserveAspect; rightWrapOffset = 431]
  221. Define SpaceCurve:
  222. :[font = input; preserveAspect; rightWrapOffset = 431]
  223. Attributes[SpaceCurve] = {HoldFirst};
  224.  
  225. SpaceCurve[fun:{_, _, _}, 
  226.   {u_, u0_, u1_, du_:((u1-u0)/(plotpoints-1))}, opts___] :=
  227.     Show[Graphics3D[Line[Table[N[fun], 
  228.                          {u,u0,u1,du}]]], opts];
  229. :[font = text; inactive; preserveAspect; rightWrapOffset = 431]
  230. Define PointSpaceCurve:
  231. :[font = input; preserveAspect; rightWrapOffset = 431]
  232. Attributes[PointSpaceCurve] = {HoldFirst}
  233.  
  234. PointSpaceCurve[fun:{_, _, _}, 
  235.   {u_, u0_, u1_, du_:((u1-u0)/(plotpoints-1))}, opts___] :=
  236.     Show[Graphics3D[Table[Point[N[fun]], 
  237.                     {u,u0,u1,du}]], opts];
  238. :[font = text; inactive; preserveAspect; rightWrapOffset = 431]
  239. End this package:
  240. :[font = input; preserveAspect; rightWrapOffset = 431; endGroup; endGroup]
  241. End[];
  242. EndPackage[];
  243. ^*)
  244.